using Dtos;
using Entities;
using Interfaces;
using Mapster;

namespace Queries;

public class ProductSkuGetQueryHandler : IRequestHandler<ProductSkuQuery, ProductSkuDto>
{
    private readonly IRepository<ProductSku, long> _repository;

    public ProductSkuGetQueryHandler(IRepository<ProductSku, long> repository)
    {
        _repository = repository;
    }

    public async Task<ProductSkuDto> Handle(ProductSkuQuery request, CancellationToken cancellationToken)
    {
        var entity = await _repository.GetAsync(request.Id);
        return entity.Adapt<ProductSkuDto>();
    }
}